﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodWorx.CMS.Plugins;

namespace MethodWorx.CMS.Workflow.IfValid
{
    public class IfValidWorkflowComponent : WorkflowComponent<IfValidConfigurationController>
    {
        public IfValidWorkflowComponent(Plugin plugin)
            : base(plugin)
        {
        }

        public static Guid ComponentId = Guid.Parse("{F604F9DA-9841-40FA-9352-4D8AD49E28E2}");

        public override Guid Id
        {
            get { return ComponentId;  }
        }

        public override string Category
        {
            get { return "Flow";  }
        }

        public override string Name
        {
            get { return "If Valid";  }
        }

        public override string Description
        {
            get { return "Provides program flow based on validation state";  }
        }

        public override string View
        {
            get { return "IfValidConfigurationView.ascx";  }
        }

        public override StepExecutionResult Execute(IWorkflowExecutionContext context, IWorkflowConfiguration configuration)
        {
            if (context.IsValid())
                return StepExecutionResult.Ok(0);
            else
                return StepExecutionResult.Ok(1);
        }
    }
}
